<?php
namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class AttributeKeyResource extends JsonResource
{
    public function toArray($request)
    {
    	$data = $this->resource;
    	
        $data = [
        	'id' => $data->id,
	        'attribute_group_id' => $data->attribute_group_id,
	        'key' => $data->key ?? '',
	        'created_at' => (string)$data->created_at,
	        
	        'attribute_values' => AttributeValueResource::collection($this->whenLoaded('attributeValues')),
        ];
        
        return $data;
    }
}
